<?php
#####################################################
# RWCARDS - Joomla E-Cards Componment!
# Copyright (C) 2004/2005 by Ralf Weber
# Company    : LoadBrain
# Homepage   : www.weberr.de
# Version    : 2.1.0
# Date       : 23/11/2005
# License    : Released under GPL
######################################################

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

if ( !defined('_RWCARDS_LANG_INCLUDED') ) 
{
  	if ( file_exists($mosConfig_absolute_path . "/components/com_rwcards/language/" . $mosConfig_lang . ".php") )
	{
    	include_once($mosConfig_absolute_path . "/components/com_rwcards/language/" . $mosConfig_lang . ".php");
  	}
	else 
	{
    	include_once($mosConfig_absolute_path . "/components/com_rwcards/language/english.php");
	}
}

class rwcards_html
{
/**
* Sets the Home button
*/	
	function setRWCardsMainscreen()
	{
	?>
		<div align="center" class="centermain">
		<table class="adminlist">
		<tr>
			<td align="center"><img src="../includes/js/ThemeOffice/home.png" alt="" border="0" align="middle">&nbsp;&nbsp;<a href="./index2.php?option=com_rwcards"><?php echo _ADMIN_RWCARDS_MAINSCREEN; ?></a></td>
		</tr>
		</table>
		</div>
	<?php
	}

/**
* 	Sets the Title 
*	Checks for already uploaded images & categories
*/	
	function setRWCardsMenu($title = "", $category, $imgFiles)
	{
	?>
<div align="center" class="centermain">
		<table class="adminlist">
		<tr>
			<td class="sectionname">>>&nbsp;<?php echo $title; ?></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		<tr class="row0">
			<td><a href="./index2.php?option=com_rwcards&task=config"><img src="./components/com_rwcards/images/admin_config_out.jpg" alt="" width="49" height="49" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_config','','./components/com_rwcards/images/admin_config_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_config"></a>&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_CONFIG_TITLE; ?></td>
		</tr>
		<tr class="row1">
			<td><a href="index2.php?option=com_rwcards&task=categories"><img src="./components/com_rwcards/images/admin_category_out.jpg" alt="" width="50" height="50" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_cats','','./components/com_rwcards/images/admin_category_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_cats"></a>&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_MANAGE_CATEGORIES; ?></td>
		</tr>
		<tr class="row0">
					<td>
					<?php
					if ($category > 0 && count($imgFiles) > 0)
					{
					?><a href="index2.php?option=com_rwcards&task=cards"><img src="./components/com_rwcards/images/admin_add_out.jpg" alt="" width="49" height="49" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_add','','./components/com_rwcards/images/admin_add_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_add"></a>&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_ADDCARD_TITLE; ?>
					<?php
					}
					else
					{
					?><img src="./components/com_rwcards/images/admin_add_out.jpg" alt="" width="49" height="49" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_add','','./components/com_rwcards/images/admin_add_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_add">&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_ADDCARD_TITLE; ?><span style="color:red;font-weight:bold;font-size:1.2em;"> <?php echo _ADMIN_RWCARDS_ADDCARD_NO_CATEGORIES_DEFINED_YET; ?></span>
					<?php
					}
					?>
					</td>
		</tr>
		<tr class="row1">
			<td><a href="index2.php?option=com_rwcards&task=sentcards"><img src="./components/com_rwcards/images/admin_manage_out.jpg" alt="" width="50" height="36" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_manage','','./components/com_rwcards/images/admin_manage_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_manage"></a>&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_MANAGE_TITLE; ?></td>
		</tr>
		<tr class="row0">
<td><a href="./index2.php?option=com_rwcards&task=upload"><img src="./components/com_rwcards/images/admin_upload_out.jpg" alt="" width="49" height="49" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_upload','','./components/com_rwcards/images/admin_upload_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_upload"></a>&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_UPLOAD_TITLE; ?></td>
		</tr>
		<tr class="row1">
			<td><a href="index2.php?option=com_rwcards&task=about"><img src="./components/com_rwcards/images/admin_about_out.jpg" alt="" width="50" height="36" border="0" align="middle" onmouseover="MM_swapImage('rw_admin_about','','./components/com_rwcards/images/admin_about_over.jpg',1);" onmouseout="MM_swapImgRestore();" name="rw_admin_about"></a>&nbsp;&nbsp;<?php echo _ADMIN_RWCARDS_ABOUT_TITLE; ?></td>
		</tr>
		</table>
</div>
	<?php
	}

/**
* Sets the Home button
*/		
	function RWCardsWriteCardData($daten)
	{
  
     $params = array(
    'itemData' => $daten,
    'perPage' => 10,
    'delta' => 8,  
    'append' => true,
    'clearIfVoid' => false,
    'urlVar' => 'entrant',
    'mode'  => 'Jumping',
    );
    
  $pager = & Pager::factory($params);
  $page_data = $pager->getPageData();
  list($from, $to) = $pager->getOffsetByPageId();
  $links = $pager->getLinks(); 
		
    if ( count( $daten ) )
		{
		?>
			<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
			<tr>
				<td align="right"><span style="border:1px solid black; background-color:#66cc99;">&nbsp;</span>&nbsp;<?php echo _ADMIN_RWCARDS_WAS_READ; ?>&nbsp;&nbsp;<span style="border:1px solid black; background-color:#ff3300;">&nbsp;</span>&nbsp;<?php echo _ADMIN_RWCARDS_WAS_NOT_READ; ?></td>
			</tr>
			</table>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" class="adminlist">
      <tr>
        <td><?php echo $links['back']; ?></td>
        <td align="center"><strong><?php echo $links['first']; ?>&nbsp;&nbsp;<?php echo  _ADMIN_RWCARDS_PAGER_ENTRY . $from . " - " . $to . _ADMIN_RWCARDS_PAGER_FROM . $pager->numItems(); ?>&nbsp;&nbsp;<?php echo $links['last']; ?></strong></td>
        <td><div align="right"><?php echo $links['next']; ?></div></td>
      </tr>
      </table>
			<table cellpadding="2" cellspacing="0" border="0" width="100%" class="adminlist">
			<tr>
				<th class="title" align="left"><?php echo _ADMIN_RWCARDS_AUTOR; ?></th>
				<th class="title"><?php echo _ADMIN_RWCARDS_EMAIL_AUTOR; ?></th>
				<th class="title"><?php echo _ADMIN_RWCARDS_EMPFAENGER; ?></th>
				<th class="title"><?php echo _ADMIN_RWCARDS_EMPFAENGER_EMAIL; ?></th>
				<th class="title"  align="center"><?php echo _ADMIN_RWCARDS_PICTURE; ?></th>
				<th class="title"  align="center"><?php echo _ADMIN_RWCARDS_MESSAGE; ?></th>
				<th class="title"  align="center"><?php echo _ADMIN_RWCARDS_READ; ?></th>
				<th class="title"  align="center"><?php echo _ADMIN_RWCARDS_DELETE; ?></th>
			</tr>
			<?php
      
      for($i = ($from - 1); $i<$to; $i++)
      {
				$image = $page_data[$i]->gelesen ? 'publish_g.png' : 'publish_x.png';
				$bgcolor = $page_data[$i]->gelesen ? '#66cc99' : '#ff3300';
			?>
				<tr bgcolor="<?php echo $bgcolor; ?>" onMouseover="this.bgColor='#A9CAEF';" onMouseout="this.bgColor='<?php echo $bgcolor; ?>';">
					<td><?php echo $page_data[$i]->nameFrom; ?></td>
					<td><?php echo $page_data[$i]->emailFrom; ?></td>
					<td><?php echo $page_data[$i]->nameTo; ?></td>
					<td><?php echo $page_data[$i]->emailTo; ?></td>
					<td><?php echo $page_data[$i]->picture;?></td>
					<td><?php echo nl2br($page_data[$i]->message);?></td>
					<td align="center"><img src="./images/<?php echo $image;?>" /></td>
					<td align="center"><a href="index2.php?option=com_rwcards&task=RWCardsDeleteReadCard&RWCardID=<?php echo $page_data[$i]->id;?>" onClick="return confirm('<?php echo _ADMIN_RWCARDS_DELETE_QUESTION; ?>')"><img src="components/com_rwcards/images/delete.gif" alt="DELETE" border="0"></a></td>
				</tr>
			<?php
			} ?>
			</table>
			<?php
		}
	}

	function setRWCardsFooter()
	{
	?>
		<br />
		<div align="center" class="small" style="color:#666666;">RWCards <?php echo _RWCARDS_VERSION; ?> Copyright &copy; 2004/2005 by <a href="http://www.weberr.de/" target="_blank">Ralf Weber - LoadBrain</a>.</div>
		<br />
		
	<?php
	}

	function setRWCardsList($daten, $selectedCategory, $categoryList)
	{
		if ( count( $daten ) )
		{
		?>
    <script language="JavaScript">
    function changeCategory()
		{
		  document.formRWCardsWriteCardList.submit();
		}
		</script>
		<form method="post"  name="formRWCardsWriteCardList" action="index2.php?option=com_rwcards&Itemid=<?php echo $_REQUEST['Itemid']; ?>">
 		<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
  	  <td align="right"><?php echo _RWCARDS_LANG_CHOSEN_CATEGORY . "<strong>" . $categoryName . "</strong>"; ?><?php echo $categoryList; ?></td>
		</tr>
    </table>
      
    <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
    <tr>
      <th class="title" align="left"><?php echo _ADMIN_RWCARDS_AUTOR; ?></th>
      <th class="title"><?php echo _ADMIN_RWCARDS_EMAIL_AUTOR; ?></th>
      <th class="title"><?php echo _ADMIN_RWCARDS_DESCRIPTION; ?></th>
      <th class="title"><?php echo _ADMIN_RWCARDS_FILE; ?></th>
      <th class="title"><?php echo _ADMIN_RWCARDS_CATEGORY; ?></th>
      <th class="title"  align="center"><?php echo _ADMIN_RWCARDS_PUBLISHED; ?></th>
      <th class="title"  align="center"><?php echo _ADMIN_RWCARDS_EDIT; ?></th>
      <th class="title"  align="center"><?php echo _ADMIN_RWCARDS_DELETE; ?></th>
      <th class="title"  align="center"><?php echo _ADMIN_RWCARDS_VIEW; ?></th>
    </tr>
    <?php
    foreach ($daten as $row)
    {      

		
	$pub = $row->published ? '0' : '1';
      $img = $row->published ? 'publish_g.png' : 'publish_x.png';
	  ?>
      <tr bgcolor="#E9ECF5" onMouseover="this.bgColor='#A9CAEF';" onMouseout="this.bgColor='#E9ECF5';">
        <td><?php echo $row->autor	; ?></td>
        <td> <?php echo $row->email; ?></td>
        <td><?php echo $row->description; ?></td>
        <td><?php echo $row->picture; ?></td>
        <td><?php echo $row->rwcards_kategorien_kategorien_name; ?></td>
        <td align="center"><a href="index2.php?option=com_rwcards&cardID=<?php echo $row->id;?>&task=RWCardsPublishCard&pub=<?php echo $pub;?>"><img src="images/<?php echo $img; ?>" width="12" height="12" border="0" alt="" /></a></td>
        <td align="center"><a href="index2.php?option=com_rwcards&task=RWCardsEditCard&cardID=<?php echo $row->id;?>"><img src="components/com_rwcards/images/edit.gif" alt="EDIT" border="0"></a></td>
        <td align="center"><a href="index2.php?option=com_rwcards&task=RWCardsDelete&cardID=<?php echo $row->id;?>" onClick="return confirm('<?php echo _ADMIN_RWCARDS_DELETE_QUESTION; ?>')"><img src="components/com_rwcards/images/delete.gif" alt="DELETE" border="0"></a></td>
        <td align="center"><a href="index2.php?option=com_rwcards&task=RWCardsViewCard&cardID=<?php echo $row->id;?>"><img src="components/com_rwcards/images/view.gif" alt="PREVIEW" border="0"></a></td>
      </tr>
    <?php
    }
    ?>
    </table>
    </form>
    <?php
		}
	else
	{
	?>
     <tr bgcolor="#E9ECF5" onMouseover="this.bgColor='#A9CAEF';" onMouseout="this.bgColor='#E9ECF5';">
        <td style="color:red; font-size:16px; text-align:center;"><?php echo _ADMIN_RWCARDS_NO_PICUTRES_AVAILABLE; ?></td>
	</tr>
	<?php
	}
}

	function setRWCardsWrite( $file)
	{
	?>
		<br />
		<table cellspacing="0" border="0" cellpadding="2">
	 	<tr>
			<td><img src="<?php echo $file; ?>" /></td>
		 </tr>
		</table>
		<br />
	<?php
	}

	function setRWCardsNewForm($imageFiles, $categoryList)
	{
	?>
		<script language="JavaScript">
		function changeImagePreview()
		{
			if (document.rwCardsForm.imageFile.value !='')
			{
				document.images['imageFile'].src = '../images/stories/cards/' + document.rwCardsForm.imageFile.value;
			}
			else
			{
				document.images['imageFile'].src = 'images/blank.png';
			}
		}
		</script>
		<form name="rwCardsForm" method="post" action="index2.php?option=com_rwcards&task=RWCardsAddNewCard">
    <table border="0" cellspacing="1" cellpadding="4" class="adminform" width=100%>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_AUTOR; ?>:</td>
      <td><input name="autor" type="text" class="inputbox"></td>
		</tr>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_FILE; ?>:</td>
			<td><?php echo $imageFiles; ?></td>
		</tr>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_CATEGORY; ?>:</td>
			<td><?php echo $categoryList; ?></td>
		</tr>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_EMAIL_AUTOR; ?>:</td>
			<td><input name="email" type="text" class="inputbox"></td>
		</tr>
		</tr>
		<tr>
			<td nowrap valign="top" width="20%">RWCard <?php echo _ADMIN_RWCARDS_DESCRIPTION; ?>:</td>
			<td><textarea name="description" id="description" class="inputbox" rows=3 cols=25></textarea></td>
		</tr>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_PUBLISHED; ?>:</td>
			<td><input type="hidden" name="published" value="0"><input type="checkbox" name="published" value="1"></td>
		</tr>
		<tr>
			<td nowrap valign="top" width="20%">RWCard <?php echo _ADMIN_RWCARDS_PREVIEW; ?>:</td>
			<td><img  name="imageFile" src="../images/stories/cards/" alt="PREVIEW" border="0"></td>
		 </tr>
		 </tr>
		 <tr>
		 	<td>&nbsp;</td>
			<td><input type="submit" name="Submit" value="<?php echo _ADMIN_RWCARDS_ADD_CARD; ?>" class="button"></td>
		</tr>
		</table>
		</form>
	<?php
	}
	function RWCardEditForm($row, $categoryList)
	{
	?>
		<script language="JavaScript">

		function changeImagePreview()
		{
			document.images['pictureFile'].src = '../images/stories/cards/' + document.rwCardsForm.imageFile.value;
		}
		</script>
		<form name="rwCardsForm" method="post" action="index2.php?option=com_rwcards&task=RWCardUpdateCard&cardID=<?php echo $row->id; ?>">
		<table border="0" cellspacing="1" cellpadding="4" class="adminform" width=100%>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_FILE; ?>:</td>
			<td><input type="text" name="imageFile" value="<?php echo $row->picture;?>" onfocus="this.blur();" style="border: 1px black solid;padding-left:5px;padding-right:5px;"></td>
		</tr>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_CATEGORY; ?>:</td>
			<td><?php echo $categoryList; ?></td>
		</tr>
		<tr>
			<td nowrap width="20%">RWCard <?php echo _ADMIN_RWCARDS_AUTOR; ?>:</td>
			<td><input name="autor" type="text" class="inputbox" value="<?php echo $row->autor; ?>"></td>
		</tr>
		</tr>
		<tr>
			<td nowrap valign="top" width="20%">RWCard <?php echo _ADMIN_RWCARDS_DESCRIPTION; ?>:</td>
			<td><textarea name="description" id="description" class="inputbox" rows=3 cols=25><?php echo $row->description; ?></textarea></td>
		</tr>
		<tr>
			<td nowrap width="20%"><?php echo _ADMIN_RWCARDS_PUBLISHED; ?>:</td>
			<td><input type="hidden" name="published" value="0"><input type="checkbox" name="published" value="1" <?if ($row->published==1){echo "checked";}?>></td>
		</tr>
		<tr>
			<td nowrap valign="top" width="20%">RWCard <?php echo _ADMIN_RWCARDS_PREVIEW; ?></td>
			<td><img  name="pictureFile" src="../images/stories/cards/<?php echo $row->picture; ?>" alt="PREVIEW" border="0"></td>
		 </tr>
		 <tr>
			<td>&nbsp;</td>
			<td><input type="submit" name="Submit" value="RWCard <?php echo _ADMIN_RWCARDS_UPDATE; ?>" class="button"></td>
		</tr>
		</table>
		</form>
		<?php
	}



function RWCardEditCategoryForm($row)
{
?>
<br />
		<form name="rwCardsCategoryForm" method="post" action="index2.php?option=com_rwcards&task=RWCardUpdateCategory&cardID=<?php echo $row->id; ?>">
		<table border="0" cellspacing="1" cellpadding="4" class="adminform" width="100%" style="border: 1px black solid;">
		<tr bgcolor="#A9CAEF">
			<td>RWCard <?php echo _ADMIN_RWCARDS_CATEGORY; ?>:&nbsp;<input name="rwcards_kategorien_kategorien_name" type="text" class="inputbox" value="<?php echo $row->rwcards_kategorien_kategorien_name; ?>">
			&nbsp;<input type="submit" name="Submit" value="RWCard <?php echo _ADMIN_RWCARDS_UPDATE . " " . _ADMIN_RWCARDS_CATEGORY; ?>" class="button"></td>
		</tr>
		</table>
		<input name="categoryId" type="hidden" value="<?php echo $row->rwcards_kategorien_id; ?>">
		</form>
<?php
}




}// end class

?>
